import { Component, OnInit } from '@angular/core';
import {ROUTE} from "../../service/route.service";
import {GOODS} from "../../service/goods-api";
import {PageParam} from "../../model/params.model";

@Component({
  selector: 'app-score-view',
  templateUrl: './score-view.component.html',
  styleUrls: ['./score-view.component.scss']
})
export class ScoreViewComponent implements OnInit {
  pageParam:PageParam;
  orderList = [];
  pagination={
    page:1,
    totalPage:1
  }

  constructor(private route:ROUTE,private GOODS:GOODS) { }

  ngOnInit() {
    this.pageParam = new PageParam()
    this.pageParam.size = 6;
    this.queryList()
  }

  goToScoreMallView(){
    this.route.goScoreMallView();
  }
  onPageChanged(v){
    console.log('onPageChanged',v.data.page)
    this.pagination.page = v.data.page
    this.pageParam.page = this.pagination.page-1
    this.queryList()
  }
  queryList() {
    this.GOODS.getScoreOrderList(v => {
      this.orderList = v.content
      this.pagination.totalPage = v.totalPages;
    },this.pageParam);
  }
}
